package com.zzzyh.springproject.service;


import com.zzzyh.springproject.mapper.AdminMapper;
import com.zzzyh.springproject.pojo.Admin;
import com.zzzyh.springproject.utils.MD5WithSaltUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author：郑雨杭
 * @date：2025-01-02 15:01:28
 */
@Service
public class AdminService {
    @Autowired
    AdminMapper adminMapper;

    public boolean login(Admin admin) {
        String pass = MD5WithSaltUtil.hashPasswordWithSalt(admin.getPassword(), admin.getSalt());
        System.out.println("================================================================");
        System.out.println(pass);
        System.out.println("================================================================");

        Admin user = adminMapper.login(admin.getUsername(), pass);
        return user != null;
    }

    public Admin getAdminByUserName(String userName) {
        return adminMapper.getAdminByUserName(userName);
    }
}
